import {getCompleteApiReleasesUrl} from "@/data/source";
import axios from "axios";
import {GithubReleasesType} from "@/types/GithubReleasesType";

/**
 * 获取发布信息
 * @param username 用户
 * @param repository 仓库
 */
export const getReleases = (username: string, repository: string): Promise<GithubReleasesType> => {
    return new Promise((resolve, reject) => {
        const apiReleases = getCompleteApiReleasesUrl({
            username: username,
            repository: repository
        });
        axios.get(apiReleases).then(res => {
            if (res && res.data) {
                resolve(res.data);
            }
            reject("获取失败");
        }).catch(e => {
            reject(e);
        })
    })
}
